home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / lib2to3 / fixes / fix_callable.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  1.2 KB  |  23 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. """Fixer for callable().
  5.  
  6. This converts callable(obj) into hasattr(obj, '__call__')."""
  7. from  import pytree
  8. from  import fixer_base
  9. from fixer_util import Call, Name, String
  10.  
  11. class FixCallable(fixer_base.BaseFix):
  12.     PATTERN = "\n    power< 'callable'\n           trailer< lpar='('\n                    ( not(arglist | argument<any '=' any>) func=any\n                      | func=arglist<(not argument<any '=' any>) any ','> )\n                    rpar=')' >\n           after=any*\n    >\n    "
  13.     
  14.     def transform(self, node, results):
  15.         func = results['func']
  16.         args = [
  17.             func.clone(),
  18.             String(', '),
  19.             String("'__call__'")]
  20.         return Call(Name('hasattr'), args, prefix = node.get_prefix())
  21.  
  22.  
  23.